home *** CD-ROM | disk | FTP | other *** search
/ Hardcore Gamer Resource Kit / Hardcore Gamer Resource Kit - Disc 3.iso / screensavers / saver17.zip / VoodooLights / Sources / cell_tp3.c < prev    next >
C/C++ Source or Header  |  1997-07-24  |  2KB  |  97 lines

  1. /*------------------------------------------------------/
  2. /                                                        /
  3. /    Copyright 1997, SΘrgio Durte <smd@di.fct.unl.pt>    /
  4. /                                                        /
  5. /------------------------------------------------------*/
  6.  
  7. #include <stdlib.h>
  8. #include <glide.h>
  9.  
  10. #include "defines.h"
  11. #include "mat.h"
  12. #include "rgb.h"
  13. #include "tex.h"
  14. #include "cam.h"
  15. #include "cell.h"
  16. #include "cell_util.h"
  17. #include "cell_tp2.h"
  18. #include "cell_tp3.h"
  19.  
  20.  
  21. static Bool first_init = True ;
  22. static GrMipMapId_t tp3_texture_src ;
  23.  
  24.  
  25. static void tp3_move_cell( Cell *c )
  26. {
  27.     mat_combv( dt, & c->vel, & c->pos, & c->pos ) ;
  28.     mat_combv( dt, & c->acc, & c->vel, & c->vel ) ;
  29.     cutl_limit_speed( c, c->max_speed ) ;
  30.     cutl_snap_pos_to_dad( c ) ;
  31. }
  32.  
  33. static void tp3_reproduce_cell( Cell *c) 
  34. {
  35.  
  36.     if( c->generation < 24 ) c->children[ c->n_chld++ ] = ctp3_Constructor( c ) ;
  37.     
  38.     c->reproduce_cell = cell_menopause ; // nπo hß mais reproduτπo
  39. }
  40.  
  41. void tp3_set_glide_state( void )
  42. {
  43.     if( first_init ) {
  44.         first_init = False ;
  45.         tp3_texture_src = tex_InitTexture("flare3.3df") ;
  46.     }    
  47.  
  48.     tex_SetTexSource( tp3_texture_src ) ;
  49.     grTexCombineFunction(GR_TMU0, GR_TEXTURECOMBINE_DECAL ) ;
  50.     guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB ) ;
  51.     guAlphaSource( GR_ALPHASOURCE_ITERATED_ALPHA );    
  52.     grAlphaBlendFunction( GR_BLEND_ONE, GR_BLEND_ONE, GR_BLEND_ONE, GR_BLEND_ZERO );
  53. }
  54.  
  55. Cell *ctp3_Constructor( Cell *dad )
  56. {
  57.  
  58.   Cell *c = cell_Constructor( CellType3 ) ;
  59.  
  60.   c->max_speed = 90.0 ;
  61.  
  62.   c->dad = dad ;
  63.  
  64.   c->max_chld = 1 ;
  65.   c->p_chld = 0.05 * rnd() + 0.05 ;
  66.  
  67.   if( dad ) {
  68.       cutl_random_pos( 1.0, c ) ;
  69.       mat_addv( & dad->pos, & c->pos, & c->pos ) ; 
  70.       
  71.       c->generation = dad->generation + 1 ;
  72.       c->adulthood = dad->adulthood ;
  73.   }    else c->adulthood = 240.0 ; 
  74.  
  75.   if( dad && dad->type == CellType2 ) c->size = 18.0 ;
  76.   else c->size = max( 6.0, dad->size - 1 ) ;
  77.   c->size +=  2*max( 0, c->generation - 22 ) ;
  78.  
  79.   if( dad && c->generation > 2 ) c->color = dad->color ;
  80.   else rgb_random_color( & c->color ) ;
  81.    
  82.   c->move_cell = tp3_move_cell ;
  83.   c->reproduce_cell = tp3_reproduce_cell ;
  84.  
  85.   return c ;
  86. }  
  87.     
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.     
  96.  
  97.